function validate()
	{
		var login = " ";
		var password = " ";
		var mail = " ";
		var regulation = " ";
		var loginReg = /^[a-zA-Z0-9]{3,30}$/;
		//w przyszlosci sprawdz czy zawiera cyfre, bo to wazne jest
		var passwordReg = /^[a-zA-Z0-9]{6,30}$/;
		
	    var f = document.forms['form'];
	    //login
	    if(!f.login.value)
	    {
	    	login = 'wprowadz login!';
	    }
	    else if(f.login.value.length < 3)
	    {
	    	login = 'zbyt krotki login!';	
	    }
	    else if(f.login.value.length >= 30)
	    {
	    	login = 'za dlugi login!';	
	    }
	    
	    else if(f.login.value.match(loginReg) == null)
	    {
	    	login = 'niepoprawny login!'; 
	    }
	    //password
	    if(!f.password1.value || !f.password2.value)
	    {
	    	password = 'wprowadz oba hasla!';
	    	
	    }
	    else if(f.password1.value != f.password2.value)
	    {
	    	password = 'hasla musza byc identczne!';
	    }	
	    else if(f.password1.value.length < 6)
	    {
	    	password = 'zbyt krotkie hasla!';
	    }
	    else if(f.password1.value.length >= 30)
	    {
	    	password = 'zbyt dlugie hasla!';

	    }
	    
	    else if(f.password1.value.match(passwordReg) == null)
	    {
	    	password = 'niepoprawne hasla!'; 
	    }
	    //mail
	    mailReg = /^[a-zA-Z0-9.]+@[a-zA-Z0-9]+(\.[a-zA-Z0-9]+)+$/;
	    if(f.mail.value.match(mailReg) == null)
	    {
	    	mail = 'niepoprawny mail!'; 
	    }   	
	    //regulation
	    if (!f.regulation.checked)
	    {
	    	regulation = 'zaakceptuj regulamin!';
	    }
	    
	    if(login == " " && password == " " && mail == " " && regulation == " ")
	    	return true;
	    else {
		  document.getElementById("login").innerHTML = login;
		  document.getElementById("password").innerHTML = password;
		  document.getElementById("mail").innerHTML = mail;
		  document.getElementById("regulation").innerHTML = regulation;
		  return false;
	    }
	  
}
function passwordStrength(password) {
    var desc = new Array();
    desc[0] = "bardzo slabe";
    desc[1] = "slabe";
    desc[2] = "srednie";
    desc[3] = "dobre";
    desc[4] = "bardzo dobre";
    
    var score   = 0;
    //if password bigger than 6 give 1 point
    if (password.length > 5) score++;
    //if password has both lower and uppercase characters give 1 point      
    if ( ( password.match(/[a-z]/) ) && ( password.match(/[A-Z]/) ) ) score++;
    //if password has at least one number give 1 point
    if (password.match(/\d+/)) score++;
    //if password bigger than 12 give another 1 point
    if (password.length > 12) score++;

    //wyswietlanie napisu
     //document.getElementById("passwordStrength").innerHTML = desc[score];
     document.getElementById("passwordStrength").className = "strength" + score;

}